//index.js
//获取应用实例
const app = getApp();
var InterFace = require('../../public/libs/interFace');
Page({
    data: {
        bannerList: [], //首页banner
        myPoint: 100 || 0,
        recommend: [],
        category: [],
        flashSale: []
    },
    onLoad() {
        wx.request({
            url: InterFace.initIndexUrl,
            method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
            success: (res) => {
                const resData = res.data;
                if (resData.succ && resData.is_succ) {
                    const banner = resData.banners;
                    if (banner && banner !== null) {
                        var bannerBoxArr = [];
                        if (banner.a0003 && banner.a0003.length > 0) {
                            bannerBoxArr.push(banner.a0003[0]);
                        }
                        if (banner.a0004 && banner.a0004.length > 0) {
                            bannerBoxArr.push(banner.a0004[0]);
                        }
                    }
                    this.setData({
                        bannerList: banner.a0001,
                        flashSale: banner.a0002,
                        bannerBox: bannerBoxArr,
                        recommend: banner.a0005
                    })

                    
                }
            }
        });
    },

})